ostbuild: Add -k option to git-mirror
authorColin Walters <walters@verbum.org>
Wed, 6 Jun 2012 02:55:47 +0000 (22:55 -0400)
committerColin Walters <walters@verbum.org>
Wed, 6 Jun 2012 02:55:53 +0000 (22:55 -0400)
libwacom's sourceforge git server was down...

src/ostbuild/pyostbuild/builtin_git_mirror.py
src/ostbuild/pyostbuild/vcs.py

index 0b7f0d58e528b815c9edb1a08a1ab531ec91f317..2b78bcf1cc0b37a1094ea97bf4b29784a96d04b5 100755 (executable)
@@ -46,6 +46,8 @@ class OstbuildGitMirror(builtins.Builtin):
                             help="Don't perform a fetch if we have done so in the last N seconds")
         parser.add_argument('--fetch', action='store_true',
                             help="Also do a git fetch for components")
+        parser.add_argument('-k', '--keep-going', action='store_true',
+                            help="Don't exit on fetch failures")
         parser.add_argument('components', nargs='*')
 
         args = parser.parse_args(argv)
@@ -95,6 +97,6 @@ class OstbuildGitMirror(builtins.Builtin):
                         continue
 
             log("Running git fetch for %s" % (name, ))
-            vcs.fetch(self.mirrordir, keytype, uri, branch_or_tag)
+            vcs.fetch(self.mirrordir, keytype, uri, branch_or_tag, keep_going=args.keep_going)
 
 builtins.register(OstbuildGitMirror)
index f47c283ed3b5b7a981984af49bad6d476fa3b48c..59d4e0394323fc7e7014b605fa1b8ba67d30ab15 100755 (executable)
@@ -141,13 +141,15 @@ def ensure_vcs_mirror(mirrordir, keytype, uri, branch):
         f.close()
     return mirror
 
-def fetch(mirrordir, keytype, uri, branch):
+def fetch(mirrordir, keytype, uri, branch, keep_going=False):
     mirror = buildutil.get_mirrordir(mirrordir, keytype, uri)
     last_fetch_path = get_lastfetch_path(mirrordir, keytype, uri, branch)
     run_sync(['git', 'fetch'], cwd=mirror, log_initiation=False) 
-    current_vcs_version = run_sync_get_output(['git', 'rev-parse', branch], cwd=mirror)
-    current_vcs_version = current_vcs_version.strip()
-    f = open(last_fetch_path, 'w')
-    f.write(current_vcs_version + '\n')
-    f.close()
+    current_vcs_version = run_sync_get_output(['git', 'rev-parse', branch], cwd=mirror,
+                                              none_on_error=keep_going)
+    if current_vcs_version is not None:
+        current_vcs_version = current_vcs_version.strip()
+        f = open(last_fetch_path, 'w')
+        f.write(current_vcs_version + '\n')
+        f.close()